<?php
/**
 * Bootstrap Doctrine.php, register autoloader specify
 * configuration attributes and load models.
 */
require_once(dirname(__FILE__) . '/doctrine/lib/Doctrine.php');

spl_autoload_register(array('Doctrine', 'autoload'));

//echo $_SERVER["SERVER_NAME"];
if($_SERVER["SERVER_NAME"] == "localhost"){
	// FOR LOCAL TESTING
	$manager = Doctrine_Manager::getInstance();
	$dsn = "mysql://root@localhost/paac";
	$connection_name = "default";
	$conn = Doctrine_Manager::connection($dsn,$connection_name);
}else{
	
	// SERVER DB
	$db['default']['dbdriver'] = "mysql";
	$db['default']['hostname'] = "db2400.perfora.net";
	$db['default']['username'] = "dbo327528756";
	$db['default']['password'] = "titan_paac";
	$db['default']['database'] = "db327528756";
	$connection_name = "default";
	
	$dsn = $db[$connection_name]['dbdriver'] .
			'://' . $db[$connection_name]['username'] .
			':' . $db[$connection_name]['password'].
			'@' . $db[$connection_name]['hostname'] .
			'/' . $db[$connection_name]['database'];
	
	//echo $dsn . "<br>";
} 
try {
	//echo "dsn = " . $dsn;
	//echo "<br> c name = ". $connection_name;
    $conn = Doctrine_Manager::connection($dsn,$connection_name);
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}
Doctrine::loadModels('models');

// (OPTIONAL) CONFIGURATION BELOW

// this will allow us to use "mutators"
Doctrine_Manager::getInstance()->setAttribute(
	Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);

// this sets all table columns to notnull and unsigned (for ints) by default
Doctrine_Manager::getInstance()->setAttribute(
	Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS,
	array('notnull' => true, 'unsigned' => true));

// set the default primary key to be named 'id', integer, 4 bytes
Doctrine_Manager::getInstance()->setAttribute(
	Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS,
	array('name' => 'id', 'type' => 'integer', 'length' => 4));

	
/*
// DB on 1and1 server
$host="db2400.perfora.net:/tmp/mysql5.sock";
$user="dbo327528756";
$password="titan_paac";
$dbname="db327528756";
*/

?>